package org.spring.core.io;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Url 相关的资源类
 *
 * @author 李坤
 * @date 2022/4/17 14:11
 */
public class UrlResource implements Resource {

    /**
     * 资源的URL
     */
    private final URL url;

    public UrlResource(URL url) {
        this.url = url;
    }

    public UrlResource(String url) throws MalformedURLException {
        this.url = new URL(url);
    }

    @Override
    public InputStream getInputStream() throws IOException {
        return this.url.openStream();
    }
}
